package com.landeb.shop.huo.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.landeb.shop.R;
import com.landeb.shop.huo.bean.ItemActSearchFlow;

import java.util.List;

/**
 * Created by blade on 2016/10/22.
 */

public class ActSearchGVAdapter extends BaseAdapter {


    private List<ItemActSearchFlow.DataBean> mList;
    private Context mContext;
    private LayoutInflater mInflater;

    public ActSearchGVAdapter(Context context, List<ItemActSearchFlow.DataBean> list) {
        mContext = context;
        mList = list;
        mInflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return mList.size();
    }

    @Override
    public Object getItem(int position) {
        return mList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHolder holder = null;
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.item_act_search_grid_view, parent, false);

            holder = new ViewHolder();

            holder.mTitle = (TextView) convertView.findViewById(R.id.tv_item_act_search_gridView);

            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        String title = mList.get(position).getName();
        holder.mTitle.setText(title);

        return convertView;
    }

    private class ViewHolder {
        private TextView mTitle; //文字
    }

}
